#pragma once

#include "IRename.h"
#include "MessageHandler.h"

class CRenameMessageHandler : public CMessageHandler<IRenameHandler>
{
public:
	CRenameMessageHandler()
	{
		m_handler = NULL;
	}

public:
	void SetHandler(IRenameHandler* handler)
	{
		m_handler = handler;
	}

public:
	virtual BOOL OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
	{
		if(m_handler == NULL)
			return FALSE;

		switch(message)
		{
		case WM_USER + 1000:
			m_handler->HandleInfo((const gtl::tchar*)lParam);
			return TRUE;

		case WM_USER + 1001:
			m_handler->HandleProgress(wParam);
			return TRUE;

		default:
			return FALSE;
		}

		return FALSE;
	}

public:
	virtual void HandleInfo(const gtl::tstr& info)
	{
		if(m_handler == NULL)
			return;

		SendMessage(m_hwnd, WM_USER + 1000, NULL, (LPARAM)info.c_str());			
	}

	virtual void HandleProgress(int percent)
	{
		if(m_handler == NULL)
			return;

		SendMessage(m_hwnd, WM_USER + 1001, percent, NULL);			
	}

protected:
	IRenameHandler* m_handler;
};